//Copyright (C) Microsoft Corporation.  All rights reserved.

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using System.Linq;
using nwind;

// See the ReadMe.html for additional information
namespace Samples {
    class Program
    {        
        static void Main(string[] args)
        {
            // The following assumes that:
            // 1. SQL Server 2005 Express is installed on your machine
            // 2. You install the Data Sample directory that contains Northwind.
            // Or, if you have installed Northwind, you will need to alter the connection string to
            // Northwind db = new Northwind("Server=.\\SQLExpress;Database=Northwind;Trusted_Connection=True");
            // You must edit the path to point to the mdf file on your machine
            // Northwind db = new Northwind("c:\\northwind\\northwnd.mdf");

            string dbPath = Path.GetFullPath(Path.Combine(Application.StartupPath, @"..\..\..\Data\NORTHWND.MDF"));
            string sqlServerInstance = @".\SQLEXPRESS";
            string connString = "AttachDBFileName='" + dbPath + "';Server='" + sqlServerInstance + "';user instance=true";

            string path = Path.GetFullPath(Path.Combine(Application.StartupPath, @"..\..\Northwind.xml"));

            System.Data.Linq.XmlMappingSource mappingSource = System.Data.Linq.XmlMappingSource.FromXml(File.ReadAllText(path));
            Northwind db = new Northwind(connString, mappingSource);
            db.Log = Console.Out;
            Samples.Sample1(db);
            Console.ReadLine();
        }
    }
}
